<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools"></t:base>
<html>
	<head>
		<style>
			.examTitle{
				text-align: center;
    			font-size: 25px;
    			font-weight: bold;
    			height: 50px;
    			line-height: 50px;
    			margin-top: 10px;
			}
			
			.subTitle{
				 height: 30px;
			    line-height: 30px;
			    text-align: center;
			    border-bottom: 1px dashed gray;
			}
			
			.button{
			    font-size: 16px;
    			margin-left: 50px;
    			margin-top: 30px;
    			padding: 5px 10px;
			}
			
			.myFooter{
				height:150px;
			}
			
			.questionList{
				padding-left:30px;
				font-size:14px;
			}
			
			.qContent{
				padding-left:10px;
			}
			
			.qContent li{
				line-height: 30px;
				height: 30px;
			}
			
			.questionItem{
				margin-top:20px;
			}
		</style>
	</head>
	<body>
		<h1 class="examTitle">安全准入在线考试</h1>
		<div class="subTitle">答题人：${LOCAL_CLINET_USER}</div>
		
		<form id="form1" method="post" action="trainExamController.do?submitExam">
			<input type="hidden" name="resultId" value="${resultId}">
			<div class="questionList" >
				<c:forEach items="${list}" var="q" varStatus="stat" >
					<div class="questionItem" data-id='${q.id}' data-num="${stat.count}">
						<div class="qTitle">${stat.count}.${q.title }</div>
						<ul class="qContent">
							<li><input name="${q.id }" type="radio" value="A"></input>A.${q.option1}</li>
							<li><input name="${q.id }" type="radio" value="B"></input>B.${q.option2}</li>
							<li><input name="${q.id }" type="radio" value="C"></input>C.${q.option3}</li>
							<li><input name="${q.id }" type="radio" value="D"></input>D.${q.option4}</li>
						</ul>						
					</div>
				</c:forEach>
			</div>
		</form>
		
		<input type="button" class="button" onclick="submitExam()" id="submitButton" value="提交试卷">
		<div class="myFooter"></div>
	</body>
	
	<script>
		 
	   
	
	
		var submit = false;
		function submitExam(){
			if(submit){
				tip("您已经提交，请勿重复提交");
				return;
			}
			
			var validateResult = true;
			$('.questionItem').each(function(){
				if(!validateResult) return;
				
				var id = $(this).attr("data-id");
				var num = $(this).attr("data-num");
				
				var val = $('input[name='+id+']:checked').length;
				if(val == 0){
					$('input[name='+id+']').focus();
					tip("第"+num+"道题未选择答案，请选择后再提交试卷！")
					validateResult = false;
				}
			});
			
			if(!validateResult) return;
			$.dialog.confirm("确定要提交试卷吗？",function(e){
				if(e){
					submit = true;
					$('#form1').submit();
				}
			});
		}
	</script>
</html>

 